package com.yonyou.pmclouds.basecom.filter;

import com.yonyou.pmclouds.basecom.runtime.DevRuntimeEnvironment;
import com.yonyou.pmclouds.basecom.runtime.RuntimeEnvironment;

import javax.servlet.*;
import java.io.IOException;

public class ThreadClearFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        try {
            chain.doFilter(request, response);
        } finally {
            RuntimeEnvironment.resetCurrentThread();
            DevRuntimeEnvironment.resetCurrentThread();
        }
    }

    @Override
    public void destroy() {

    }
}
